from tkinter import *
import random
from math import sin, cos, pi, sqrt

root = Tk()
size = 600
height = 800
rotateMultiplier = 20
squareSize = 40
cv = Canvas(root, width =830, height = 900, bg = 'white')
i = squareSize + 30
while i <= size - squareSize:
    j = squareSize
    while j <= height - squareSize:
        plusOrMinus = -1 if random.random() < 0.5 else 1
        rotateAmt = j / size * pi / 180 * plusOrMinus *\
             random.random() * rotateMultiplier
        if j >= height // 2:
            j += random.random() * 3
        coord = ( 
            i ,j,
            i + squareSize * cos(rotateAmt),\
                 j - squareSize * sin(rotateAmt),
            i + squareSize * (cos(rotateAmt) - sin(rotateAmt)),\
                 j - squareSize * (cos(rotateAmt) + sin(rotateAmt)),
            i - squareSize * sin(rotateAmt), j - squareSize * cos(rotateAmt)
            )
        cv.create_polygon(coord, fill ='white', outline = "black")
        j += squareSize
    i += squareSize
cv.pack()
root.mainloop()













